#ifndef UDockableH
#define UDockableH
#include "stdafx.h"
#include "UVector.h"
#include "UGLFontObj.h"

#include "UWindowManager.h"
#include "UGLFont.h"
#include "UVector.h" //for gluProject

class TDockable //Window with (optional) border
{
	friend class TWindowThemer;
private:
	bool bordersVisible;
	int mouseX;
	int mouseY;
	TControlContainer* themecontrols;
protected:
	TWindowThemer *windowthemer;
	TGLFontRef GLFont;
	TGLFontObj* WindowCaptionRenderer;

public:
	//FIXME: This needs to be placed somewhere better, me thinks
	TVector gluProject(const TVector& v);
	TVector gluUnProject(const TVector& v);


	TWindowThemer* getWindowThemer() { return windowthemer; };

	TDockable(TRectangle Rect, TContainerWindow* parent, TWindowThemer *wt, std::string name);
	~TDockable();
	TContainerWindow* Parent;
	std::string Name;
	int Left;
	int Top;
	int Right;
	int Bottom;
	int Width();
	int Height();

	bool Contains	(int X, int Y);
	bool ResizeAtPos(int X, int Y);
	virtual void SetPos(TRectangle Rect);

	virtual TNonSpaceFillingContainerWindow* GetRoot();

	virtual bool Dock(TDockable* WindowToDock, int X, int Y);

	virtual void Draw();
	virtual void KeyDown	(SDL_KeyboardEvent* Key);
	virtual void KeyUp(SDL_KeyboardEvent* Key);
	virtual void MouseMove(int X, int Y, int mstate);
	virtual void MouseLeave ();
	virtual void MouseDown	(int X, int Y, uint8 button);
	virtual void MouseUp	(int X, int Y, uint8 button);

	TWindowManager::MOUSE_CURSOR testfunc() {};

	void Close();
	void ToggleBorders();
	virtual void AddToPopUpMenu(TPopUpMenu* Menu);
	virtual bool IsFocussed();

	virtual TDockable* FindWindowByTag(int Tag) = 0; //NOTE: NULL is an invalid pure specifier (only `= 0' is allowed) before ';' token

};
#endif
